var RenYuan = new Vue({

    el : '#JingshangHuizonglist',
    data :{

        danweiid:'',
        truename:'',
        renyuanleibie:'',
        jigoumingchengma:'',
        paixu:'jigoumingchengma',
        renyuan : {},
        jingshang:{},
        renyuanlist : [],
        renyuanleibielist:[],
        jingshangqingkuanglist:[],
        danweinamelist:[],


        editFlag : 0,					// 0:新增，1：修改
        show : false,					// 显示列表是否有数据
        jingshangqingkuang: false,

        pageIndex : 1,
        pageSize :6,
        pageCount : 0,
        recordCount : 0,
        inputPageIndexValue : "",


    },
    created : function() {

        this.findVaild(0);
        this.initDict();
        this.selectDepNameByValid();

    },
    methods : {
        // 绑定字典表
        initDict : function() {
            var _this = this;

            // 人员类别
            $.post("../dict_renyuanleibie/find_valid", {
                rdm : Math.random()
            }, function (ppData) {
                if (ppData != null) {
                    if (ppData.result == '1') {
                        var data = ppData.resultContent;
                        _this.renyuanleibielist = data;
                    } else {
                        layer.alert(ppData.message);
                    }
                }
            }, "json");
        },

        selectDepNameByValid : function() {
            var _this = this;

            // 单位名称
            $.post("../dept/findcengji_by_deptid", {
                deptid: 0,
                rdm : Math.random()
            }, function (ppData) {
                if (ppData != null) {
                    if (ppData.result == '1') {
                        var data = ppData.resultContent;
                        _this.danweinamelist = data;
                    } else {
                        layer.alert(ppData.message);
                    }
                }
            }, "json");
        },

        findVaild: function(ppFlag){
            var _this = this;
            if (ppFlag==1){
                _this.pageIndex=1;
            }
            layer.open({type:3});
            $.post("../jingshangqingkuang/find_custom_by_deptid",{
                deptid : _this.danweiid,
                truename: _this.truename,
                renyuanleibie: _this.renyuanleibie,
                jigoumingchengma:_this.jigoumingchengma,
                paixu:_this.paixu,
                pageindex : _this.pageIndex,
                pagesize : _this.pageSize,
                rdm : Math.random()
            },function(ppData){
                layer.closeAll("loading");
                if (ppData != null){
                    if(ppData.result == "1"){
                        var data=ppData.resultContent;

                        var mmHtml = "<table class=\"table table-bordered\" style=\"margin-bottom:10px;overflow:hidden;\" v-if=\"show\" cellspacing=\"0\" cellpadding=\"0\">\n" +
                            "                    <tr style=\"font-weight: bold;\">\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 40px;\" rowspan=\"3\">序号</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;\" colspan=\"11\" >人员信息</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;\" colspan=\"10\" >配偶、子女及其配偶经商办企业情况</td>\n" +
                            "                    </tr>\n" +
                            "                    <tr style=\"font-weight: bold;\">\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;\" colspan=\"7\">干部信息</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;\" colspan=\"2\" >配偶、子女及其配偶信息</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 40px;\" rowspan=\"2\">是否存在配偶、子女及其配偶经商办企业情形</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 60px;\" rowspan=\"2\">身份证号码</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 60px;\"  rowspan=\"2\">企业名称</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 100px;\"  rowspan=\"2\">经营范围</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 60px;\"  rowspan=\"2\">经营状态</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 60px;\"  rowspan=\"2\">认缴出资额（万元）</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 60px;\"  rowspan=\"2\">在企业所任职务</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 60px;\"  rowspan=\"2\">近三年排在前5名的销售商品或服务名称</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 60px;\"  rowspan=\"2\">近三年排在前5名的交易对象名称</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 100px;\"  colspan=\"2\">目前是否存在与单位单位有直接经济利益关系情况</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;\"  rowspan=\"2\">近三年发生过直接经济利益关系的单位单位名称</td>\n" +
                            "                    </tr>\n" +
                            "                    <tr style=\"font-weight: bold;\">\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 50px;\" >姓名</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 50px;\"  >机构名称码</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 80px;\"  >部职别</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 50px;\"  >人员类别</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 50px;\"  >出生年月</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 60px;\"  >军衔等级及时间</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 100px;\"  >职务层级（级别）及时间</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 50px;\"  >姓名</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 50px;\"  >与干部关系</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 40px;\"  >是/否</td>\n" +
                            "                        <td style=\"text-align:center;vertical-align:middle;width: 60px;\"  >单位单位名称</td>\n" +
                            "                    </tr>";
                        if(data.RenyuanList.length > 0){
                            _this.show = true;
                            _this.renyuanlist=data.RenyuanList;

                            var PageInfo = data.PageInfo;
                            _this.pageIndex = PageInfo.pageIndex;
                            _this.recordCount = PageInfo.recordCount;
                            _this.pageCount = PageInfo.pageCount;


                            /*for (var i = 0; i < _this.renyuanlist.length; i++) {
                                var renyuan = _this.renyuanlist[i];
                                var renyuanid = renyuan.RENYUANID;
                                var tr = document.getElementById(renyuanid);
                                var table = document.getElementById(renyuanid+"table");
                                var htr = tr.offsetHeight;    // 返回元素的总宽度
                                var htable = table.offsetHeight;    // 返回元素的总宽度

                                if (htr>htable){
                                    document.getElementById(renyuanid+"table").style.height=htr;
                                }
                            }*/
                            for (var i = 0; i < data.RenyuanList.length; i++) {
                                var mmRenyuan = data.RenyuanList[i];
                                var mmIndex = i+1;
                                var mmTruename = mmRenyuan.truename;
                                var mmJigoumingchengma = mmRenyuan.jigoumingchengma;
                                var mmBuzhibie = mmRenyuan.buzhibie;
                                var mmRenyuanleibie = mmRenyuan.renyuanleibietext;
                                var mmChusheng = mmRenyuan.chusheng2;
                                var mmJunxian = mmRenyuan.junxianleibietext+mmRenyuan.junxiandengjitext;
                                var mmJunxianshijian = "";
                                if (mmRenyuan.JUNXIANSHIJIAN2!=undefined){
                                    mmJunxianshijian = mmRenyuan.JUNXIANSHIJIAN2;
                                }
                                var mmZhiwucengji = mmRenyuan.zhiwucengjitext;
                                var mmZhiwushijian = mmRenyuan.zhiwushijian2;
                                var mmHebingshu = mmRenyuan.hebinghang;
                                var mmHebinghang ="";
                                if (mmHebingshu>1){
                                    mmHebinghang = "rowspan='"+mmHebingshu+"'";
                                }else{
                                    mmHebinghang = "";
                                }
                                var mmJiashuList = mmRenyuan.jiashujingshanglist;
                                mmHtml += "<tr>";
                                mmHtml += "<td style='text-align:center;vertical-align:middle;width: 40px;height: 100%'"+mmHebinghang+">"+mmIndex+"</td>";
                                mmHtml += "<td style='text-align:center;vertical-align:middle;width: 50px;height: 100%'"+mmHebinghang+">"+mmTruename+"</td>";
                                mmHtml += "<td style='text-align:center;vertical-align:middle;width: 50px;height: 100%'"+mmHebinghang+">"+mmJigoumingchengma+"</td>";
                                mmHtml += "<td style='text-align:center;vertical-align:middle;width: 80px;height: 100%'"+mmHebinghang+">"+mmBuzhibie+"</td>";
                                mmHtml += "<td style='text-align:center;vertical-align:middle;width: 50px;height: 100%'"+mmHebinghang+">"+mmRenyuanleibie+"</td>";
                                mmHtml += "<td style='text-align:center;vertical-align:middle;width: 50px;height: 100%' "+mmHebinghang+">"+mmChusheng+"</td>";
                                mmHtml += "<td style='text-align:center;vertical-align:middle;width: 60px;height: 100%' "+mmHebinghang+"><div>"+mmJunxian+"</div><div>"+mmJunxianshijian+"</div></td>";
                                mmHtml += "<td style='text-align:center;vertical-align:middle;width: 100px;height: 100%'"+mmHebinghang+"><div>"+mmZhiwucengji+"</div><div>"+mmZhiwushijian+"</div></td>";

                                if (mmJiashuList.length==0){
                                    mmHtml += "<td colspan='14'></td></tr>";
                                }
                                for (var j = 0; j < mmJiashuList.length; j++) {
                                    var mmJiashu = mmJiashuList[j];
                                    var mmXingming = mmJiashu.name;
                                    var mmGuanxi = mmJiashu.guanxitext;
                                    var mmShifoujingshang = mmJiashu.shifoujingshang;
                                    var mmShenfenzhenghao = mmJiashu.shenfenzhenghao;
                                    var mmHebingshu2 = mmJiashu.hebinghang;
                                    var mmJingshangList = mmJiashu.jingshanglist;
                                    var mmHebinghang2 ="";
                                    if (mmHebingshu2>1){
                                        mmHebinghang2 = "rowspan='"+mmHebingshu2+"'";
                                    }else{
                                        mmHebinghang2 ="";
                                    }

                                    var mmHuanhangfu = "";
                                    if(j!=0){
                                        mmHuanhangfu = "<tr>";
                                    }
                                    mmHtml += mmHuanhangfu+"<td style='text-align:center;vertical-align:middle;width: 49px;height: 100%'"+mmHebinghang2+">"+mmXingming+"</td>";
                                    mmHtml += "<td style='text-align:center;vertical-align:middle;width: 50px;height: 100%'"+mmHebinghang2+">"+mmGuanxi+"</td>";
                                    mmHtml += "<td style='text-align:center;vertical-align:middle;width: 45px;height: 100%'"+mmHebinghang2+">"+mmShifoujingshang+"</td>";
                                    mmHtml += "<td style='text-align:center;vertical-align:middle;width: 60px;height: 100%'"+mmHebinghang2+">"+mmShenfenzhenghao+"</td>";

                                    if (mmJingshangList.length==0){
                                        mmHtml += "<td colspan='10'></td></tr>";
                                    }
                                    for (var k = 0; k < mmJingshangList.length; k++) {
                                        var mmJingshang = mmJingshangList[k];
                                        var mmQiyename=mmJingshang.qiyename;
                                        var mmJingyingfanwei=mmJingshang.jingyingfanwei;
                                        var mmJingyingzhaungtai=mmJingshang.jingyingzhuangtaitext;
                                        var mmChuzie=mmJingshang.renjiaochuzie;
                                        var mmZhiwu=mmJingshang.zhiwutext;
                                        var mmQianwushangpin=mmJingshang.qianwushangpinhuofuwuname;
                                        var mmQianwuduixiang=mmJingshang.qianwujiaoyiduixiangname;
                                        var mmShifouzhijie=mmJingshang.shifouyouzhijieguanxi;
                                        if (mmShifouzhijie=="1"){
                                            mmShifouzhijie="是";
                                        }else {
                                            mmShifouzhijie="否";
                                        }
                                        var mmJunduimingcheng=mmJingshang.shijunduimingcheng;
                                        var mmJinshanniandanwei=mmJingshang.jinsanzhijieguanximingcheng;

                                        var mmHuanhangfu2 = "";
                                        if (k!=0){
                                            mmHuanhangfu2 = "<tr>";
                                        }
                                        mmHtml += mmHuanhangfu2+"<td style='text-align:center;vertical-align:middle;width: 49px;height: 100%'>"+mmQiyename+"</td>";
                                        mmHtml += "<td style='text-align:center;vertical-align:middle;width: 50px;height: 100%'>"+mmJingyingfanwei+"</td>";
                                        mmHtml += "<td style='text-align:center;vertical-align:middle;width: 45px;height: 100%'>"+mmJingyingzhaungtai+"</td>";
                                        mmHtml += "<td style='text-align:center;vertical-align:middle;width: 60px;height: 100%'>"+mmChuzie+"</td>";
                                        mmHtml += "<td style='text-align:center;vertical-align:middle;width: 49px;height: 100%'>"+mmZhiwu+"</td>";
                                        mmHtml += "<td style='text-align:center;vertical-align:middle;width: 50px;height: 100%'>"+mmQianwushangpin+"</td>";
                                        mmHtml += "<td style='text-align:center;vertical-align:middle;width: 45px;height: 100%'>"+mmQianwuduixiang+"</td>";
                                        mmHtml += "<td style='text-align:center;vertical-align:middle;width: 40px;height: 100%'>"+mmShifouzhijie+"</td>";
                                        mmHtml += "<td style='text-align:center;vertical-align:middle;width: 60px;height: 100%'>"+mmJunduimingcheng+"</td>";
                                        mmHtml += "<td style='text-align:center;vertical-align:middle;width: 50px;height: 100%'>"+mmJinshanniandanwei+"</td></tr>";

                                    }


                                }

                            }


                        }else {
                            _this.show = false;
                        }
                        mmHtml += "</table>";
                        $("#List").html(mmHtml);
                    }else{
                        layer.alert(ppData.message);
                    }
                }

            },"json");
        },


        Daochu: function(){
            var _this = this;
            window.open("../jingshangqingkuang/daochu?deptid="+_this.danweiid+"&renyuanleibie="+_this.renyuanleibie+"&jigoumingchengma="+_this.jigoumingchengma+"&paixu="+_this.paixu);

        },

        //跳到首页
        SetPageIndex : function(){
            this.pageIndex = 1;
        },
        SetPageEnd : function(){
            this.pageIndex = this.pageCount;
        },
        //上一页
        SetPageIndexPrePage : function(){
            var PrePage = ((this.pageIndex -1) <= 0) ? 1 : (this.pageIndex -1);
            this.pageIndex = PrePage;
        },
        //下一页
        SetPageIndexNextPage : function(){
            var NextPage = ((this.pageIndex +1) >= this.pageCount) ? this.pageCount : (this.pageIndex +1);
            this.pageIndex = NextPage;
        },
        //跳转界面
        JumpPage : function(){
            if(this.inputPageIndexValue <= 1){
                this.inputPageIndexValue = 1;
            }else if(this.inputPageIndexValue >= this.pageCount){
                this.inputPageIndexValue = this.pageCount;
            }
            this.pageIndex = this.inputPageIndexValue;
            this.inputPageIndexValue = '';
        },




    },
    watch :{
        //监控分页情况，刷新列表
        pageIndex : function(){

            this.findVaild(0);
        }
    }

});
